<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateTableCustomerCouponUseHistory extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('customer_coupon_use_history', function (Blueprint $table) {
            $table->id();

            $table->unsignedBigInteger("customerCouponId")->comment("用户优惠券id");
            $table->unsignedBigInteger("couponId")->comment("优惠券id");
            $table->string("couponCode")->default("")->comment("优惠券code");
            $table->unsignedTinyInteger("type")->comment("核销类型 1 - 核销 2 - 撤回")->default(0);
            $table->unsignedBigInteger("shopId")->comment("门店id")->default(0);
            $table->unsignedTinyInteger("useType")->comment("渠道 1 - 商家端")->default(0);
            $table->unsignedInteger("operateTime")->comment("操作时间")->default(0);


            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('updatedAt')->default(0)->comment('更新时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('更新人');
            $table->tinyInteger("isDeleted")->default(0)->comment("是否删除,0:未删除,1:已删除");
        });

        $prefix = config('other.DB_PREFIX', '');
        \Illuminate\Support\Facades\DB::statement("ALTER TABLE `{$prefix}customer_coupon_use_history` COMMENT = '用户优惠券核销记录'"); //表注释
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('customer_coupon_use_history');
    }
}
